from django.contrib import admin
from utils .admin import MyAdmin
from .models import *
from apps.sale.models import Customer,Contacts


class QuotationInline(admin.TabularInline):
    model = Quotation


# 客户联系人和客户同页显示
class ContactsInline(admin.TabularInline):
    model = Contacts


@admin.register(Customer)
class CustomerAdmin(MyAdmin):
    inlines =[ContactsInline,]
    list_display = ('A001', 'F001', 'B001', 'B002', 'B003', 'B004')
    search_fields = ('B001','B003')


@admin.register(SampleApply)
class SampleApplyAdmin(admin.ModelAdmin):
    list_display = ('F002','F003','B001','B002','B003','B004','B005','B006','B007')
    search_fields = ('F002','F003')


class DemandImageInline(admin.TabularInline):
    model = DemandImage


@admin.register(DemandGathering)
class DemandGatheringAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': ('F001', 'F002')
        }),
        ('应用场景', {
            'fields': ('D001','D002','D003','D004','D005','D006','D007','D008','D009','D010','D011','D012','D013')
        }),
        ('保护膜信息', {
            'fields': ('E001','E002','E003','E004','E005','E006','E007','E008','E009')
        }),
        ('其他信息', {
            'fields': ('G001','G002','G003','G004','G005')
        }),
    )
    inlines = [DemandImageInline,]


admin.site.register(Quotation)

